package com.ruoyi.web.controller.order;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.WaterWorkRecord;
import com.ruoyi.system.service.IWaterWorkRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 意见信息Controller
 * 
 * @author ruoyi
 * @date 2025-09-29
 */
@RestController
@RequestMapping("/service/orderRecord")
public class WaterWorkRecordController extends BaseController
{
    @Autowired
    private IWaterWorkRecordService waterWorkRecordService;

    /**
     * 查询意见信息列表
     */
    @PreAuthorize("@ss.hasPermi('service:orderRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(WaterWorkRecord waterWorkRecord)
    {
        startPage();
        List<WaterWorkRecord> list = waterWorkRecordService.selectWaterWorkRecordList(waterWorkRecord);
        return getDataTable(list);
    }

    /**
     * 导出意见信息列表
     */
    @PreAuthorize("@ss.hasPermi('service:orderRecord:export')")
    @Log(title = "意见信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WaterWorkRecord waterWorkRecord)
    {
        List<WaterWorkRecord> list = waterWorkRecordService.selectWaterWorkRecordList(waterWorkRecord);
        ExcelUtil<WaterWorkRecord> util = new ExcelUtil<WaterWorkRecord>(WaterWorkRecord.class);
        util.exportExcel(response, list, "意见信息数据");
    }

    /**
     * 获取意见信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('service:orderRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(waterWorkRecordService.selectWaterWorkRecordById(id));
    }

    /**
     * 新增意见信息
     */
    @PreAuthorize("@ss.hasPermi('service:orderRecord:add')")
    @Log(title = "意见信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WaterWorkRecord waterWorkRecord)
    {
        waterWorkRecord.setRecordUserName(getUsername());
        return toAjax(waterWorkRecordService.insertWaterWorkRecord(waterWorkRecord));
    }

    /**
     * 修改意见信息
     */
    @PreAuthorize("@ss.hasPermi('service:orderRecord:edit')")
    @Log(title = "意见信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WaterWorkRecord waterWorkRecord)
    {
        return toAjax(waterWorkRecordService.updateWaterWorkRecord(waterWorkRecord));
    }

    /**
     * 删除意见信息
     */
    @PreAuthorize("@ss.hasPermi('service:orderRecord:remove')")
    @Log(title = "意见信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(waterWorkRecordService.deleteWaterWorkRecordByIds(ids));
    }
}
